package net.yxsoft.controller.pc.sysmgt;

import com.jfinal.aop.Before;
import com.jfinal.plugin.activerecord.Record;
import net.yxsoft.controller.pc.sysmgt.common.AuthController;
import net.yxsoft.controller.pc.sysmgt.common.interceptor.AuthInterceptor;
import net.yxsoft.controller.pc.sysmgt.common.interceptor.LoginDbSessionInterceptor;

import net.yxsoft.model.formdesigner.FnFormData;
import net.yxsoft.resource.CodeRes;
import net.yxsoft.service.ApplyService;
import rapid.util.StrKit;

import java.util.List;


/**
* @MethodName: 链卡申请
* @Description:
* @param: null
* @return * @return null
* @throws
* @date 2023/9/6 15:27
* @author jhf
*/
@Before({ LoginDbSessionInterceptor.class,AuthInterceptor.class})
public class ApplyForController extends AuthController {
    private static final ApplyService asr = ApplyService.INSTANCE;



    /**
    * @MethodName: getMoreBlockView
    * @Description:  获取跨链的区块列表
    * @param:
    * @return void
    * @throws
    * @date 2023/10/16 15:19
    * @author wj
    */
    public void getMoreBlockView() {
        String rq=get("rq");
        String hs=get("hs");
        String kg=get("kg");
        String jd=get("jd");

        String rqks=rq==null?"":rq.substring(0,10);
        String rqjs=rq==null?"":rq.substring(12,23);
        String val=get(0);
        if(StrKit.notBlank(val)) {
            set("val", val);
            Record count=asr.getBlockListcount(rqks, rqjs, hs, kg, jd, val);
            set("count",count==null?0:count.get("count"));
            set("lklist", asr.getBlockListall(rqks, rqjs, hs, kg, jd, val));

        render("block.html");
        }else {
            redirect("/sysadmin/block/browserkl");
        }
    }


    /**
    * @MethodName: getMoreTXView
    * @Description: 获得交易列表
    * @param:
    * @return void
    * @throws
    * @date 2023/10/23 15:06
    * @author wj
    */
    public void getMoreTXView() {
        String rq=get("rq");
        String hs=get("hs");
        String lid=get("lid");
        String fq=get("fq");

        String rqks=rq==null?"":rq.substring(0,10);
        String rqjs=rq==null?"":rq.substring(12,23);
        String val=get(0);
        if(StrKit.notBlank(val)) {
            set("val", val);
            List<Record> count=asr.getTxListall(rqks, rqjs, hs, lid, fq, val);
            set("count",count==null?0:count.size());
            set("Txlist", count);

            render("txList.html");
        }else {
            redirect("/sysadmin/block/browserkl");
        }
    }

    /**
    * @MethodName: viewTxCtransaction
    * @Description: 获取交易详情
    * @param: 
    * @return void
    * @throws
     * @date 2023/10/25 09:31
    * @author wj 
    */
    public void viewTxCtransaction(){
        String txcid=get(0);
        if(StrKit.notBlank(txcid)) {

            Record record=  asr.getTxinfo(txcid);
            set("txinfo", record);
            render("txinfo.html");

        }else {
            redirect("/sysadmin/block/browserkl");
        }

    }


    /**
    * @MethodName: viewCtransaction
    * @Description: 获取区块详情
    * @param:
    * @return void
    * @throws
    * @date 2023/10/16 21:10
    * @author wj
    */
    public void viewCtransaction(){
        String blockcid=get(0);
        if(StrKit.notBlank(blockcid)) {

            Record record= asr.getBlockInfo(blockcid);
            set("block", record);
            if(record!=null && record.getInt("attrib_11")!=null && StrKit.notBlank(record.getStr("attrib_02"))) {
                List<Record> count = asr.getBlockidByTxList(record.getInt("attrib_11"),record.getStr("attrib_02"));

                set("count", count == null ? 0 : count.size());
                set("bktxlist", count);
                render("blockinfo.html");
            }else {
                redirect("/sysadmin/block/browserkl");
            }
        }else {
            redirect("/sysadmin/block/browserkl");
        }

    }



}
